package com.cfjjc.gz.usraccount.service;

import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cfjjc.gz.common.consts.SystemConst;
import com.cfjjc.gz.common.consts.TradeInfoConst;
import com.cfjjc.gz.common.consts.TypeValueConst;
import com.cfjjc.gz.common.dao.DefaultDAO;
import com.cfjjc.gz.common.exception.OTSException;
import com.cfjjc.gz.common.service.BaseService;
import com.cfjjc.gz.common.util.DateTimeUtil;
import com.cfjjc.gz.common.util.MD5;
import com.cfjjc.gz.common.util.RandomGUID;
import com.cfjjc.gz.common.util.StringUtil;
import com.cfjjc.gz.common.util.paged.PagedList;
import com.cfjjc.gz.usraccount.vo.A_USRVO;



@Service
@Transactional(rollbackFor = Throwable.class)
public class A_USRService extends BaseService {

	/**
	 * logger对象
	 */
	private static final Logger logger = Logger.getLogger(A_USRService.class);

	@Autowired
	private DefaultDAO dao;

/*	@Autowired
	private D_PWD_POLICYService d_PWD_POLICYService;
	
    @Autowired
    private B_USR_CREDENCEService b_USR_CREDENCEService;*/
	

	// 要访问的dao的命名空间
	private String namespace = "A_USR";

	public A_USRService() {
		super();
	}

	/**
	 * 仅查询单条用户信息表的详细信息
	 */
	public A_USRVO queryA_USR(A_USRVO param) throws OTSException {
		return (A_USRVO) dao.queryObject(param, this.namespace);
	}

	/**
	 * 根据条件检索用户信息表，返回分页结果
	 */
	public void queryA_USRs(A_USRVO param, PagedList records)
			throws OTSException {
		dao.queryPagedList(param, records, this.namespace);
	}
	
	/**
	 * 根据条件检索用户信息表，返回所有结果
	 */
	public List<A_USRVO> queryA_USRList(A_USRVO param) throws OTSException {
		return dao.queryList(param, this.namespace);
	}
	
	/**
	 * 根据会话日志的结束时间条件检索在线用户信息，返回所有结果
	 */
	public List<A_USRVO> queryMonitorA_USRList(A_USRVO param) throws OTSException {
		return dao.queryList(param, this.namespace, "queryMonitor");
	}
	

	/**
	 * 增加用户信息表
	 */
	public void doInsertA_USR(A_USRVO param) throws OTSException {

		param.setKey(RandomGUID.getRandomGuid());
		param.setIs_hide(SystemConst.NO_CONST);
		param.setNode_id(SystemConst.NODE_ID); // TODO 临时写死
		param.setIs_hide(SystemConst.YES_CONST);
		param.setCreate_at(DateTimeUtil.getDateTime());
		param.setFirst_login(SystemConst.YES_CONST);

		// 录入前的校验
		_checkFields(param, SystemConst.OPERATION_TYPE_NEW);

		// 校验统一登录名是否重复
		A_USRVO query = new A_USRVO();
		query.setLogin_name(param.getLogin_name());
		//query.setContainsDeleted(SystemConst.NO_CONST);
		//query.setUsr_status(TypeValueConst.USR_STATUS_LOGOUT);
		A_USRVO res = (A_USRVO) this.dao.queryObject(query, this.namespace);

		if (res != null) {
			throw new OTSException("当前身份证号：" + param.getLogin_name() + " 已存在!");
		}

		dao.insert(param, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("增加一条用户信息表记录:" + param);
		}
		
		// 记录操作日志
	//	insertTradeLog(TradeInfoConst.TRADE_ADD_USR, param.getUsr_name(), param);
	}

	/**
	 * 修改用户信息表
	 */
	public void doUpdateA_USR(A_USRVO param) throws OTSException {/*
		
		// 修改前的校验
		_checkFields(param, SystemConst.OPERATION_TYPE_MODIFY);

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		A_USRVO res = (A_USRVO) this.queryA_USR(query);

		if (res == null) {
			throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}
		
		if(TypeValueConst.USR_STATUS_LOGOUT.equals(res.getUsr_status())){
			throw new OTSException("已删除的用户不允许修改操作！");
		}
		
		param.setUpdate_at(DateTimeUtil.getDateTime()); 
		dao.update(param, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + param);
		}
		
		// 记录操作日志
		insertTradeLog(TradeInfoConst.TRADE_MODIFY_USR, param.getUsr_name(), param);
	*/}
	
	/**
	 * 自助服务，修改个人信息
	 */
	public void doUpdateInformation(A_USRVO param) throws OTSException {
		
		// 修改前的校验
		_checkFields(param, SystemConst.OPERATION_TYPE_MODIFY);

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		A_USRVO res = (A_USRVO) this.queryA_USR(query);

		if (res == null) {
	//		throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}
		
		if(TypeValueConst.USR_STATUS_LOGOUT.equals(res.getUsr_status())){
			throw new OTSException("已删除的用户不允许修改操作！");
		}
		
		param.setUpdate_at(DateTimeUtil.getDateTime()); 
		dao.update(param, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + param);
		}
		
		// 记录操作日志
		//insertTradeLog(TradeInfoConst.TRADE_UPDATEINFORMATION, param.getUsr_name(), param);
	}
	
	/**
	 * 修改密码
	 */
	public void doUpdateA_USR_pwd(A_USRVO param) throws OTSException {
		
		if(param.getUsr_id() == null || "".equals(param.getUsr_id())){
			throw new OTSException("主键字段不允许为空！");
		}
		
		if(param.getStatic_pwd_md5() == null || "".equals(param.getStatic_pwd_md5())){
			throw new OTSException("静态密码字段不允许为空！");
		}
		
		if(param.getNew_static_pwd_md5() == null || "".equals(param.getNew_static_pwd_md5())){
			throw new OTSException("新的静态密码字段不允许为空！");
		}
		
		if(param.getRe_new_static_pwd_md5() == null || "".equals(param.getRe_new_static_pwd_md5())){
			throw new OTSException("重复静态密码字段不允许为空！");
		}
		
		if(!param.getNew_static_pwd_md5().equals(param.getRe_new_static_pwd_md5())){
			throw new OTSException("两次新密码不一致，请重新输入！");
		}
		
		A_USRVO usr = new A_USRVO();
		usr.setUsr_id(param.getUsr_id());
		A_USRVO rs_usr = this.queryA_USR(usr);
		
		if(rs_usr == null){
		 	throw new OTSException("此用户不存在，或者登录已经失效，请重新登录！");
		}
		
		if(!rs_usr.getStatic_pwd_md5().equals(MD5.encodeByMD5(param.getStatic_pwd_md5()))){
			throw new OTSException("原始密码验证失败！");
		}
		
//		if(!d_PWD_POLICYService.checkUsrPwd(param.getNew_static_pwd_md5())){
//			throw new OTSException("新密码不符合默认密码规则！");
// 		}
		
		String updateTime = DateTimeUtil.getDateTime();
		rs_usr.setStatic_pwd_md5(MD5.encodeByMD5(param.getNew_static_pwd_md5()));
		rs_usr.setUpdate_at(updateTime);
		dao.update(rs_usr, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("修改密码:" + rs_usr);
		}
		
//		insertTradeLog(TradeInfoConst.TRADE_MODIFY_USR_PWD, rs_usr.getUsr_name(), rs_usr);
		
/*		B_USR_CREDENCEVO credence = new B_USR_CREDENCEVO();
		credence.setUsr_id(rs_usr.getUsr_id());
		credence.setFail_count("0");
		credence.setUpdate_by(param.getUpdate_by());
		credence.setUpdate_at(updateTime);
		dao.update(credence, "B_USR_CREDENCE");*/
	}	

	/**
	 * 删除用户信息表
	 */
	public void doDeleteA_USR(A_USRVO param) throws OTSException {
		// 删除前的校验
		_checkFields(param, SystemConst.OPERATION_TYPE_DELETE);

		A_USRVO queryUsr = new A_USRVO();
		queryUsr.setUsr_id(param.getUsr_id());
		A_USRVO res = this.queryA_USR(queryUsr);
		if (res == null) {
			throw new OTSException("要操作的记录不存在,请刷新页面后重试或联系管理员!");
		}

		// 先删除已经挂接的用户组关系
//		A_USR_USRGRPVO query_usrgrp = new A_USR_USRGRPVO();
//		query_usrgrp.setUsr_id(param.getUsr_id());// 设置用户id
//
//		List<A_USR_USRGRPVO> rs_az05 = this.a_USR_USRGRPService
//				.queryA_USR_USRGRPList(query_usrgrp);
//
//		for (A_USR_USRGRPVO res_usrgrp : rs_az05) {
//			this.a_USR_USRGRPService.doDeleteA_USR_USRGRP(res_usrgrp);
//		}

		res.setUpdate_by(param.getUpdate_by());
		res.setUpdate_at(DateTimeUtil.getDateTime());
		res.setUsr_status(TypeValueConst.USR_STATUS_LOGOUT);
		dao.update(res, this.namespace);
		if (logger.isDebugEnabled()) {
			logger.debug("删除用户信息表:" + res);
		}
		
		// 记录操作日志
	//	insertTradeLog(TradeInfoConst.TRADE_DEL_USR, res.getUsr_name(), res);
	}

	/**
	 * 保存为用户分配凭证- 密码信封
	 * @return 
	 */
/*	public String doApplyCredence(A_USRVO param) throws OTSException {
		
		String defaultPwd = "" ;
		if (param.getUsr_id() == null
				|| "".equals(String.valueOf(param.getUsr_id()))) {
			throw new OTSException("用户ID不能为空！");
		}

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		
		A_USRVO res_up = this.queryA_USR(query);
		if (res_up == null) {
			throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}

		D_PWD_POLICYVO pwd_policy = new D_PWD_POLICYVO();
		pwd_policy.setIs_enable(SystemConst.YES_CONST);
		pwd_policy.setPwd_type(TypeValueConst.USR_PWD_TYPE);

		D_PWD_POLICYVO res_pwd_policy = this.d_PWD_POLICYService.queryD_PWD_POLICY(pwd_policy);
		if (res_pwd_policy == null) {
			throw new OTSException("用户密码策略错误，请检查用户密码策略！");
		}

		defaultPwd = this.d_PWD_POLICYService.generateUsrPwd();

		res_up.setStatic_pwd_md5(MD5.encodeByMD5(defaultPwd));

		String updateTime = DateTimeUtil.getDateTime();
		res_up.setRelease_form(param.getRelease_form()); // 01:密码信封  02:管理员设置
		res_up.setIs_long_term(param.getIs_long_term());
		res_up.setEffect_time(param.getEffect_time());
		res_up.setExpire_time(param.getExpire_time());
		res_up.setUpdate_at(updateTime);
		res_up.setUpdate_by(param.getUpdate_by());

		if (StringUtil.getLength(res_up.getStatic_pwd_md5()) > 50) {
			throw new OTSException("静态口令内容长度不能大于50位,请检查！");
		}

		if (StringUtil.getLength(res_up.getIs_long_term()) > 1) {
			throw new OTSException("是否长期有效内容长度不能大于1位,请检查！");
		}
		
		res_up.setFirst_login(SystemConst.YES_CONST);
		dao.update(res_up, this.namespace);
		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + res_up);
		}

		B_USR_CREDENCEVO usr_credence = new B_USR_CREDENCEVO();
		usr_credence.setUsr_id(res_up.getUsr_id());
		usr_credence.setAuth_mode(SystemConst.AUTH_MODE_STATIC_PWD);
		
		if(SystemConst.OPERATION_TYPE_NEW == Integer.valueOf(param.getIs_static_create_or_update())){
			usr_credence.setFail_count("0");
			usr_credence.setCreate_at(updateTime);
			usr_credence.setCreate_by(param.getUpdate_by());
			usr_credence.setUsr_credence_status(TypeValueConst.USR_TOKEN_NORMAL);
			b_USR_CREDENCEService.doInsertB_USR_CREDENCE_Static(usr_credence);
			insertTradeLog(TradeInfoConst.TRADE_ADD_CREDENCE_STATIC, res_up.getUsr_name(), usr_credence);
		}else if(SystemConst.OPERATION_TYPE_MODIFY == Integer.valueOf(param.getIs_static_create_or_update())){
			//用户重置静态口令
			B_USR_CREDENCEVO credence = b_USR_CREDENCEService.queryB_USR_CREDENCE(usr_credence);
			credence.setFail_count("0");
			credence.setUpdate_by(param.getUpdate_by());
			credence.setUpdate_at(updateTime);
			credence.setUsr_credence_status(TypeValueConst.USR_TOKEN_NORMAL);
            b_USR_CREDENCEService.doUpdateB_USR_CREDENCE(credence);
            insertTradeLog(TradeInfoConst.TRADE_RESET_CREDENCE_MANAGE, res_up.getUsr_name(), credence);
		}
		return defaultPwd;
	}*/
	
	/**
	 * 保存为用户分配凭证- 管理员设置
	 * @return 
	 */
	public void doApplyCredenceAdminSetup(A_USRVO param) throws OTSException {/*
		
		if (param.getUsr_id() == null || "".equals(String.valueOf(param.getUsr_id()))) {
			throw new OTSException("用户ID不能为空！");
		}
		
		if (param.getStatic_pwd_md5() == null || "".equals(String.valueOf(param.getStatic_pwd_md5()))) {
			throw new OTSException("管理员设置密码不能为空！");
		}

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		
		A_USRVO res_up = this.queryA_USR(query);
		if (res_up == null) {
			throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}
		
		if(!d_PWD_POLICYService.checkUsrPwd(param.getStatic_pwd_md5())){
			throw new OTSException("新密码不符合默认密码规则！");
		}

		String updateTime = DateTimeUtil.getDateTime();
		res_up.setRelease_form(param.getRelease_form());
		res_up.setStatic_pwd_md5(MD5.encodeByMD5(param.getStatic_pwd_md5()));
		res_up.setIs_long_term(param.getIs_long_term());
		res_up.setEffect_time(param.getEffect_time());
		res_up.setExpire_time(param.getExpire_time());
		res_up.setUpdate_at(updateTime);
		res_up.setUpdate_by(param.getUpdate_by());
		
		if (StringUtil.getLength(res_up.getStatic_pwd_md5()) > 50) {
			throw new OTSException("静态口令内容长度不能大于50位,请检查！");
		}

		if (StringUtil.getLength(res_up.getIs_long_term()) > 1) {
			throw new OTSException("是否长期有效内容长度不能大于1位,请检查！");
		}

		res_up.setFirst_login(SystemConst.YES_CONST);
		dao.update(res_up, this.namespace);
		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + res_up);
		}
		
	//	B_USR_CREDENCEVO usr_credence = new B_USR_CREDENCEVO();
		usr_credence.setUsr_id(res_up.getUsr_id());
		usr_credence.setAuth_mode(SystemConst.AUTH_MODE_STATIC_PWD);

		if (SystemConst.OPERATION_TYPE_NEW == Integer.valueOf(param.getIs_static_create_or_update())) {
			//新增静态口令
			usr_credence.setFail_count("0");
			usr_credence.setCreate_by(param.getCreate_by());
			usr_credence.setCreate_at(updateTime);
			usr_credence.setUsr_credence_status(TypeValueConst.USR_TOKEN_NORMAL);
//			b_USR_CREDENCEService.doInsertB_USR_CREDENCE_Static(usr_credence);
//			insertTradeLog(TradeInfoConst.TRADE_ADD_CREDENCE_STATIC, res_up.getUsr_name(), usr_credence);
		} else if (SystemConst.OPERATION_TYPE_MODIFY == Integer.valueOf(param.getIs_static_create_or_update())) {
			// 用户重置静态口令
			B_USR_CREDENCEVO credence = b_USR_CREDENCEService.queryB_USR_CREDENCE(usr_credence);
			credence.setFail_count("0");
			credence.setUpdate_by(param.getUpdate_by());
			credence.setUpdate_at(updateTime);
			credence.setUsr_credence_status(TypeValueConst.USR_TOKEN_NORMAL);
			b_USR_CREDENCEService.doUpdateB_USR_CREDENCE(credence);
			insertTradeLog(TradeInfoConst.TRADE_RESET_CREDENCE_MANAGE, res_up.getUsr_name(), credence);
		} 

	*/}
	
	/**
	 * 保存用户时间策略授权
	 */
	public void doUpdateA_USRbyTimePolicy(A_USRVO param) throws OTSException {
		
		// 修改前的校验
		if(param.getUsr_id() == null || "".equals(param.getUsr_id())){
			throw new OTSException("用户ID不能为空！");
		}
		if(param.getTime_policy_id() == null || "".equals(param.getTime_policy_id())){
			throw new OTSException("时间策略ID不能为空！");
		}

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		A_USRVO res = (A_USRVO) this.queryA_USR(query);

		if (res == null) {
	//		throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}
		
		if(res.getTime_policy_id() != null && !"".equals(res.getTime_policy_id())){
			throw new OTSException(res.getUsr_name() + " 已授权时间策略！");
		}

		res.setTime_policy_id(param.getTime_policy_id());
		dao.update(res, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + res);
		}
		
	//	insertTradeLog(TradeInfoConst.TRADE_ADD_USR_AUTH_TIME_POLICY, res.getUsr_name(), res);
	}
	
	/**
	 * 删除用户授权时间策略
	 */
	public void doDeleteTimePolicyOperation(A_USRVO param) throws OTSException {
		
		// 修改前的校验
		if(param.getUsr_id() == null || "".equals(param.getUsr_id())){
			throw new OTSException("用户ID不能为空！");
		}

		A_USRVO query = new A_USRVO();
		query.setUsr_id(param.getUsr_id());
		A_USRVO res = (A_USRVO) this.queryA_USR(query);

		if (res == null) {
		//	throw new OTSException(ErrorInfoConst.CURRENT_UPDATE_ROW_IS_NOT_EXISTS);
		}
		
		if(res.getTime_policy_id() == null || "".equals(res.getTime_policy_id())){
			throw new OTSException(res.getUsr_name() + " 未授权时间策略！");
		}

		res.setTime_policy_id("");
		dao.update(res, this.namespace);

		if (logger.isDebugEnabled()) {
			logger.debug("修改用户信息表:" + res);
		}
		
	//	insertTradeLog(TradeInfoConst.TRADE_DEL_USR_AUTH_TIME_POLICY, res.getUsr_name(), res);
	}

	/** 以下为私有方法.私有方法应以下划线"_"开头 */
	/**
	 * 对当前的操作对象进行字段级的校验<br>
	 * 
	 * @param param
	 *            待操作的vo对象
	 * @param opeType
	 *            操作类型,见SystemConst中定义的常数
	 * 
	 * @see com.mofit.fs.yhbs.common.SystemConst
	 */
	private void _checkFields(A_USRVO param, int opeType) throws OTSException {
		if (logger.isDebugEnabled()) {
			logger.debug("对待保存的对象进行字段校验,操作类型opeType=" + opeType);
		}
		/*
		 * 除操作类型为insert外,主键字段不能为空
		 */
		if (opeType != SystemConst.OPERATION_TYPE_NEW) {

			if (param.getUsr_id() == null
					|| "".equals(String.valueOf(param.getUsr_id()))) {
				throw new OTSException("用户ID不能为空！");
			}

		}
		/*
		 * 对于操作类型为insert,非主键字段中不允许null的字段不能为空
		 */
		if (opeType == SystemConst.OPERATION_TYPE_NEW
				|| opeType == SystemConst.OPERATION_TYPE_MODIFY) {

			if (param.getLogin_name() == null
					|| "".equals(String.valueOf(param.getLogin_name()))) {
				throw new OTSException("统一登录名不能为空！");
			}

			if (param.getUsr_type() == null
					|| "".equals(String.valueOf(param.getUsr_type()))) {
				throw new OTSException("用户类型不能为空！");
			}

			if (param.getUsr_name() == null
					|| "".equals(String.valueOf(param.getUsr_name()))) {
				throw new OTSException("用户姓名不能为空！");
			}

			if (param.getOrg_id() == null
					|| "".equals(String.valueOf(param.getOrg_id()))) {
				throw new OTSException("所属机构不能为空！");
			}

			if (param.getIs_leader() == null
					|| "".equals(String.valueOf(param.getIs_leader()))) {
				throw new OTSException("是否负责人不能为空！");
			}

			if (param.getIs_operator() == null
					|| "".equals(String.valueOf(param.getIs_operator()))) {
				throw new OTSException("是否操作员不能为空！");
			}

			if (param.getIs_hide() == null
					|| "".equals(String.valueOf(param.getIs_hide()))) {
				throw new OTSException("是否隐藏不能为空！");
			}

			if (param.getUsr_status() == null
					|| "".equals(String.valueOf(param.getUsr_status()))) {
				throw new OTSException("用户状态不能为空！");
			}

			if (param.getNode_id() == null
					|| "".equals(String.valueOf(param.getNode_id()))) {
				throw new OTSException("节点ID不能为空！");
			}

		}

		/*
		 * 对于操作类型为insert或update,字段长度不能超过表中字段长度
		 */
		if (opeType == SystemConst.OPERATION_TYPE_NEW
				|| opeType == SystemConst.OPERATION_TYPE_MODIFY) {

			if (StringUtil.getLength(param.getLogin_name()) > 50) {
				throw new OTSException("统一登录名内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getUsr_type()) > 50) {
				throw new OTSException("用户类型内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getUsr_name()) > 150) {
				throw new OTSException("用户姓名内容长度不能大于150位,请检查！");
			}

			if (StringUtil.getLength(param.getOrg_id()) > 50) {
				throw new OTSException("所属机构内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getPhone()) > 50) {
				throw new OTSException("固定电话内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getMobile()) > 50) {
				throw new OTSException("手机号码内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getEmail()) > 50) {
				throw new OTSException("邮箱内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getIs_leader()) > 1) {
				throw new OTSException("是否负责人内容长度不能大于1位,请检查！");
			}

			if (StringUtil.getLength(param.getIs_operator()) > 1) {
				throw new OTSException("是否操作员内容长度不能大于1位,请检查！");
			}

			if (StringUtil.getLength(param.getIs_hide()) > 1) {
				throw new OTSException("是否隐藏内容长度不能大于1位,请检查！");
			}

			if (StringUtil.getLength(param.getUsr_status()) > 50) {
				throw new OTSException("用户状态内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getStatic_pwd_md5()) > 50) {
				throw new OTSException("静态口令内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getStatic_pwd_md5()) > 50) {
				throw new OTSException("发放形式内容长度不能大于50位,请检查！");
			}

			if (StringUtil.getLength(param.getIs_long_term()) > 1) {
				throw new OTSException("是否长期有效内容长度不能大于1位,请检查！");
			}

			if (StringUtil.getLength(param.getEffect_time()) > 19) {
				throw new OTSException("生效时间内容长度不能大于19位,请检查！");
			}

			if (StringUtil.getLength(param.getExpire_time()) > 19) {
				throw new OTSException("失效时间内容长度不能大于19位,请检查！");
			}

			if (StringUtil.getLength(param.getUsr_desc()) > 255) {
				throw new OTSException("描述内容长度不能大于255位,请检查！");
			}

			if (StringUtil.getLength(param.getNode_id()) > 50) {
				throw new OTSException("节点ID内容长度不能大于50位,请检查！");
			}

		}

		if (logger.isDebugEnabled()) {
			logger.debug("字段校验通过");
		}
	}
}